<%@page import="cn.sendto.mapper.IRowMapper"%>
<%@page import="cn.sendto.model.ClassEntity"%>
<%@page import="java.util.List"%>
<%@page import="cn.sendto.mapper.ClassMapper"%>
<%@page import="cn.sendto.dbhelper.DBHelper"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="getSession.jsp" %>
<html>
	<head>
		<meta charset="UTF-8">
		<title>课程列表页面</title>
		<link rel="stylesheet" type="text/css" href="css/global.css"/>
		<style type="text/css">
			.list{
				width: 95%;
				font-size: 18px;
				text-align: center;
				margin: 0 auto;
				border: 1px solid darkgray;
				margin-top:3%;
			}
			.list ul{
				height: 30px;
				border-bottom: 1px dashed darkgray;
			}
			.list ul li{
				float: left;
				width: 25%;
				line-height: 30px;
				text-align: center;
				overflow: hidden;
			}
			ul:last-child{
				border-bottom: none;
			}
			ul:first-child{
			    font-weight:bold;
				background-color: #CCC;
			}
			a:hover{
				position: relative;
				top: 1px;
				right: 1px;
				color: royalblue;
				text-shadow: 3px 5px 4px #000000;
			}
			.weight{
				font-weight: bold;
			}
		</style>
	</head>
	<body>
	<%
	  if(request.getAttribute("info")!=null)
	  {
		  %>
		  <script type="text/javascript">
		  alert('<%=request.getAttribute("info")%>');
		  </script>
		  <%
	  }
	%>
    	<h4 style="text-align: center; margin-top: 3%;font-size:30px;">班级信息列表</h4>
		<div style="width:95%; text-align: right;margin-top: 10px;"><a href="add_class.jsp"><span style="font-size:25px">添加班级</span></a></div>
		<div class="list">
					<ul class="weight">
				<li>序号</li>
				<li>名称</li>
				<li>修改</li>
				<li>删除</li>
			</ul>
			<%
			    DBHelper helper = new DBHelper();
			
			    String sql = "select * from classinfo";
			
				IRowMapper mapper = new ClassMapper();
				List<ClassEntity> list = helper.executeQuery(sql, mapper, null);

				helper.close();
				
				for(int i=0; i<list.size();i++){%>
				
				<ul>
					<li><%=i+1 %></li>
					<li><%=list.get(i).getClassName() %></li>
					<li><a href="modifyClass.jsp?id=<%=list.get(i).getClassId()%>">修改</a></li>
					<li><a href="delClass.jsp?id=<%=list.get(i).getClassId()%>" onclick='return confirm("确定要删除此班级信息吗？")'>删除</a></li>
				</ul>
				<%
				}
			%>
		</div>
	</body>
</html>
